package com.itheima.tanhua.vo;

import com.itheima.tanhua.domain.UserInfo;
import com.itheima.tanhua.mongo.Acoustic;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class AcousticVo {

    private Integer id;
    private String avatar; //用户头像
    private String nickname; //昵称
    private String gender; //性别
    private Integer age; //年龄
    private String soundUrl; //语音文件，URL
    private Integer remainingTimes; //	剩余次数

    public static AcousticVo init(UserInfo userInfo, Acoustic acoustic, Integer remainingTimes) {
        AcousticVo vo = new AcousticVo();
        //copy用户属性
        BeanUtils.copyProperties(userInfo, vo);  //source,target
        //进行语音路径的拷贝
        vo.setSoundUrl(acoustic.getSoundUrl());
        //次数的设置
        vo.setRemainingTimes(remainingTimes);
        //设置id
        vo.setId(userInfo.getId().intValue());
        return vo;
    }
}
